import { Injectable } from '@angular/core'
import { ISearchOption } from '@shared/interfaces/search'
import { I18NService } from '@core'

@Injectable({
  providedIn: 'root',
})
export class HelperService {

  constructor(
    public i18n: I18NService,
  ) {}

  generateOptionsFromEnum = (e: any): ISearchOption[] => {
    const options = []
    for (const val in e) {
      options.push({ label: this.trans(e[val]), value: val })
    }
    return options
  }

  trans(key: string, params?: Object): string {
    return this.i18n.fanyi(key, params)
  }

}
